URL = "http://www.ffmpeg.org/releases/ffmpeg-%(VERSION)s.tar.bz2"
VERSIONS = ["0.6.1", "0.6.3"]
DEFAULT_VERSION = "0.6.3"

from source.builders import ConfigureMakeBuilder
from source.builders import NotImplementedException
import os

class FFmpegBuilder( ConfigureMakeBuilder ):
  """ subclass of ConfigureMakeBuilder with custom configure step """
  def configure(self):
    os.chdir( self.extractedpath )

    if self.machine.isWindows():
      raise NotImplementedException( "TODO: we need mingw")
      #self.execute( "./configure --prefix=" + self.installpath() + " --disable-debug --enable-memalign-hack\
      #--disable-static --enable-shared --disable-ffplay --disable-ffserver --disable-network\
      #--disable-devices" )
      # win64
      #--disable-debug --enable-memalign-hack --disable-static --enable-shared --disable-ffplay --disable-ffserver --disable-vhook --disable-network --enable-hardcoded-tables --prefix=/c/temp/ffmpeg_win64 --disable-devices --cross-prefix=x86_64-pc-mingw32- --enable-cross-compile --target-os=mingw32 --arch=x86_64

    else:
      # The cflag _GNU_SOURCE is needed to NOT have the dependency on GLIBC_2.7
      # but use an older version of scanf. This will be fixed in ffmpeg-0.6
      self.execute( "./configure --prefix=" + self.installpath() + " --disable-debug --disable-static\
        --enable-shared --disable-ffplay --disable-ffserver --disable-network\
        --disable-devices --extra-cflags=-D_GNU_SOURCE" )

  def install(self):
    ConfigureMakeBuilder.install(self)
    os.chdir( self.extractedpath )
    self.copyfile( "libavcodec/imgconvert.h", self.installpath() +"/include/libavcodec" )

BUILDER = FFmpegBuilder

